﻿// ***********************************************************************
// Assembly         : MVC4Portal
// Author           : Lolo
// Created          : 06-16-2013
//
// Last Modified By : Lolo
// Last Modified On : 10-11-2013
// ***********************************************************************
// <copyright file="LayoutManagerController.cs" company="">
//     Copyright (c) . All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using INNOVACALL.Framework.Common.MVCHelpers;
using INNOVACALL.Framework.Common.Models;

namespace InnovaApp.Portals.MVC4Portal.Controllers
{
    /// <summary>
    /// Class LayoutManagerController TODO Verify if used
    /// </summary>
    public class LayoutManagerController : Controller
    {
        private Dictionary<string, string> Layouts;
        private string eMethodBase = "InnovaApp.Portals.InnovaAppFrontOfficePortal.Controllers.LayoutManagerController";

        /// <summary>
        /// Initializes a new instance of the <see cref="LayoutManagerController"/> class OBSOLETE.
        /// </summary>
        public LayoutManagerController()
        {
            this.Layouts = new Dictionary<string, string>();
            Layouts.Add("Layout01", "<div class='MyPrettyCMSContentLayout {0} grid'><div class='MyPrettyCMSContentLayout mceEditable unit whole'>{1}</div></div>");
            Layouts.Add("Layout02H", "<div class='MyPrettyCMSContentLayout {0} grid'><div class='MyPrettyCMSContentLayout mceEditable unit whole'>{1}</div><div class='MyPrettyCMSContentLayout mceEditable unit whole'>&nbsp;</div></div>");
            Layouts.Add("Layout02V", "<div class='MyPrettyCMSContentLayout {0} grid'><div class='MyPrettyCMSContentLayout mceEditable unit half'>{1}</div><div class='MyPrettyCMSContentLayout mceEditable  unit half'>&nbsp;</div></div>");

            Layouts.Add("Layout031", @"<div class='MyPrettyCMSContentLayout {0} grid'>
<div class='MyPrettyCMSContentLayout mceEditable unit whole'>{1}</div>
<div class='MyPrettyCMSContentLayout grid'>
    <div class='MyPrettyCMSContentLayout mceEditable unit half'>&nbsp;</div>
    <div class='MyPrettyCMSContentLayout mceEditable unit half'>&nbsp;</div>
</div>
</div>");
            Layouts.Add("Layout032", @"<div class='MyPrettyCMSContentLayout {0} grid'>
<div class='MyPrettyCMSContentLayout grid'>
    <div class='MyPrettyCMSContentLayout mceEditable unit half'>{1}</div>
    <div class='MyPrettyCMSContentLayout mceEditable unit half'>&nbsp;</div>
</div>
<div class='MyPrettyCMSContentLayout mceEditable unit whole'>&nbsp;</div>
</div>");
            Layouts.Add("Layout041", @"<div class='MyPrettyCMSContentLayout {0} grid'>
<div class='MyPrettyCMSContentLayout grid'>
    <div class='MyPrettyCMSContentLayout mceEditable unit half'>{1}</div>
    <div class='MyPrettyCMSContentLayout mceEditable unit half'>&nbsp;</div>
</div>
<div class='MyPrettyCMSContentLayout grid'>
    <div class='MyPrettyCMSContentLayout mceEditable unit half'>&nbsp;</div>
    <div class='MyPrettyCMSContentLayout mceEditable unit half'>&nbsp;</div>
</div>
</div>");
            Layouts.Add("Layout042", @"<div class='MyPrettyCMSContentLayout {0} grid'>
<div class='MyPrettyCMSContentLayout mceEditable unit half'>{1}</div>
<div class='MyPrettyCMSContentLayout unit half'>
<div class='MyPrettyCMSContentLayout grid'>
    <div class='MyPrettyCMSContentLayout mceEditable unit whole'>&nbsp;</div>
    <div class='MyPrettyCMSContentLayout mceEditable unit whole'>&nbsp;</div>
    <div class='MyPrettyCMSContentLayout mceEditable unit whole'>&nbsp;</div>
</div>
</div>
</div>");
        }

        /// <summary>
        /// Gets the layout.
        /// </summary>
        /// <param name="LayoutId">The layout identifier.</param>
        /// <param name="Content">The content.</param>
        /// <returns>JsonResult.</returns>
        [HttpPost, Authorize, CacheManager(enCacheMode.NoCache)]
        public JsonResult GetLayout(string LayoutId, string Content)
        {
            string eMethod = eMethodBase + "GetLayout[POST]";
            object eParameters = new { LayoutId = LayoutId };
            JsonResult toReturn = new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet };
            toReturn.Data = new INNOVACALLAjaxResponse(
                success:true,
                domElementToUpdate:null,
                htmlContent: string.Format(Layouts[LayoutId], LayoutId, Content),
                scriptToExecute:null,
                messageTitle:null,
                message:null,
                additionalData:null
            );
            return toReturn;
        }

    }
}
